import Vue from 'vue';
import zh from 'vee-validate/dist/locale/zh_CN';
import VeeValidate, { Validator } from 'vee-validate';

// Localize takes the locale object as the second argument (optional) and merges it.
Validator.localize('zh_CN', zh);
Validator.extend('mobile', {
  getMessage: field => `${field}请输入11位的手机号码`,
  validate: value => value.length === 11 && /^((13|14|15|16|17|18)[0-9]{1}\d{8})$/.test(value),
});
const config = {
  errorBagName: 'errors',
  delay: 0, // 错误提示的延迟时间
  locale: 'zh_CN', // 对语言（中文）的配置
  strict: true, // 没有设置规则的表单不进行校验，
  enableAutoClasses: false,
  events: 'blur|change',
  inject: true,
  fieldsBagName: 'vee-fields',
};
// Install the Plugin.
Vue.use(VeeValidate, config);
